package com.widetrust.carpro.dao.userright;

import java.sql.Types;
import java.util.Arrays;
import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
import org.springframework.transaction.annotation.Transactional;

import com.widetrust.carpro.domain.userright.Users;
import com.widetrust.carpro.orm.RowMapperForSpringJDBC;
import com.widetrust.common.MyString;
import com.widetrust.config.sqlbeans.Statements;
import com.widetrust.helper.ResourceUtils;

public class UserRightDao extends NamedParameterJdbcDaoSupport implements IUserRightDao {
	public List<Users> readUserRight(String userid) {

		Statements statements=ResourceUtils.getStatements();
		String sql=statements.getSQLStatement("secrchuser");
		
		String[] args=new String[]{userid};
		List<Users> userright = getJdbcTemplate().query(
				sql, args,
			new RowMapperForSpringJDBC(Users.class));
		return userright;
		
		
	}
	

public boolean updateUserRight(Users users, String userid) {
	
	
	Statements statements=ResourceUtils.getStatements();
	String sql=statements.getSQLStatement("updateRight");
	
	SqlParameterSource sqlParameterSource=new BeanPropertySqlParameterSource(users);
	
	int result = getNamedParameterJdbcTemplate().update(sql,sqlParameterSource);

	if(result==1){
		return true;
	}else{
		return false;
	}

}
}